#include <stdio.h>

int sumOddLengthSubarrays(int* arr, int arrSize) {
    int sum = 0;
    
    for (int i = 1; i <= arrSize; i += 2) {
        for (int j = 0; j <= arrSize - i; j++) {
            for (int k = j; k < j + i; k++) {
                sum += arr[k];
            }
        }
    }
    
    return sum;
}

int main() {
    int arr[100]; 
    int arrSize;

    printf("请输入数组的大小：");
    scanf("%d", &arrSize);
    
    printf("请输入数组元素：\n");
    for (int i = 0; i < arrSize; i++) {
        scanf("%d", &arr[i]);
    }
    
    int result = sumOddLengthSubarrays(arr, arrSize);
    printf("所有奇数长度子数组的和为：%d\n", result);
    
    return 0;
}